package kr.co.doriclassic.mylibrary;


import javax.swing.JPanel;

import java.awt.GridLayout;

import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.JComboBox;

public class ComboPanel extends JPanel {
	private static final long serialVersionUID = 1L;
	private JLabel lbl;
	private JComboBox cb;
	
	public ComboPanel() {
		initialize();
	}
	
	public ComboPanel(String lblStr){
		initialize();
		lbl.setText(lblStr);
	}
	
	private void initialize() {
		setLayout(new GridLayout(0, 2, 10, 5));
		
		lbl = new JLabel("New label");
		lbl.setHorizontalAlignment(SwingConstants.RIGHT);
		add(lbl);
				
		cb = new JComboBox();
		add(cb);
	}
	public void setLbl(String title) {
		this.lbl.setText(title);
	}
	
	public String getItemCb(int i) {
		return (String) cb.getItemAt(i);
	}
	
	public String getSelectedCb(){
		return (String) cb.getSelectedItem();
	}
	public void addCb(String...str) {
		for(int i = 0; i<str.length; i++)
		{
			cb.addItem(str[i]);
		}
	}
	public void insertCb(String...str) {
		for(int i = 0; i<str.length; i++)
		{
			cb.insertItemAt(str[i],i);
		}
	}
	
	public JComboBox<Object> getCb() {
		return cb;
	}
	
	public void setSelectedCb(Object obj){
		cb.setSelectedItem(obj);
	}
}